Skip to main content

traceroute command

traceroute - trace the route to a host

The traceroute command in Linux is a network diagnostic tool used to trace the route packets take from your system to a destination host. It shows each hop (intermediate router or server) along the path, helping you identify network issues like delays or failures.

Note: traceroute may not be installed by default on some systems (e.g., Ubuntu). Install it with sudo apt install traceroute or use tracepath as an alternative.

Usage: traceroute [option ...] host [packet_size]

  • host: The destination (e.g., google.com, 192.168.1.1).
  • packet_size: Optional size of probe packets (in bytes).
  • options: Flags to modify behavior.

Examples

  • Basic Usage

    Run traceroute with a destination to see the path packets take.

    traceroute google.com
    • Output (example):
      traceroute to google.com (142.250.190.78), 30 hops max, 60 byte packets
      1 192.168.1.1 (192.168.1.1) 2.345 ms 2.567 ms 2.789 ms
      2 10.0.0.1 (10.0.0.1) 5.123 ms 5.456 ms 5.789 ms
      3 isp-gateway (203.0.113.1) 10.234 ms 10.567 ms 10.890 ms
      4 * * *
      5 google-edge (142.250.190.78) 15.678 ms 15.901 ms 16.123 ms
    • Explanation:
      • 1, 2, 3...: Hop number (each router or gateway).
      • IP (name): Address and hostname of the hop.
      • ms: Round-trip time for three probes per hop.
      • * * *: No response (timeout or blocked).
  • Limiting Hops

    Use -m to set the maximum number of hops.

    traceroute -m 10 google.com
    • Stops after 10 hops (default is 30).
  • Specifying Probes

    Use -q to set the number of probes per hop (default is 3).

    traceroute -q 1 google.com
    • Output shows only one time per hop:
      1  192.168.1.1 (192.168.1.1)  2.345 ms
      2 10.0.0.1 (10.0.0.1) 5.123 ms
  • Using IP Only

    Use -n to skip hostname resolution (faster).

    traceroute -n google.com
    • Output:
      1  192.168.1.1  2.345 ms  2.567 ms  2.789 ms
      2 10.0.0.1 5.123 ms 5.456 ms 5.789 ms
    • Shows IPs without resolving to names.
  • Setting Packet Size

    Specify packet size (in bytes) to test network behavior.

    traceroute google.com 100
    • Uses 100-byte packets instead of the default (60).
  • Changing Protocol

    By default, traceroute uses UDP. Use -I for ICMP (like ping).

    traceroute -I google.com
    • Sends ICMP echo requests instead of UDP packets.
$ traceroute --help
Usage: traceroute [OPTION...] HOST
Print the route packets trace to network host.

-f, --first-hop=NUM set initial hop distance, i.e., time-to-live
-g, --gateways=GATES list of gateways for loose source routing
-I, --icmp use ICMP ECHO as probe
-m, --max-hop=NUM set maximal hop count (default: 64)
-M, --type=METHOD use METHOD (`icmp' or `udp') for traceroute
operations, defaulting to `udp'
-p, --port=PORT use destination PORT port (default: 33434)
-q, --tries=NUM send NUM probe packets per hop (default: 3)
--resolve-hostnames resolve hostnames
-t, --tos=NUM set type of service (TOS) to NUM
-w, --wait=NUM wait NUM seconds for response (default: 3)
-?, --help give this help list
--usage give a short usage message
-V, --version print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

For more details, check the manual with man traceroute